#include "virus.h"
#include "utils.h"
#include <stdlib.h>

Virus::Virus(int vir, int infect, int drugres, int immuneres, int hp, QObject *parent)
    : QObject(parent)
{
    Virulence = vir;
    Infectivity = infect;
    DrugResistance = drugres;
    ImmuneResistance = immuneres;
    StartingHp = hp;

    int mutatechance = 10;

    if(rand() % 100 < mutatechance)
    {
        Infectivity += (rand() % 100) - (rand() % 100);
    }
    if(rand() % 100 < mutatechance)
    {
        Virulence += (rand() % 100) - (rand() % 100);
    }
    if(rand() % 100 < mutatechance)
    {
        DrugResistance += (rand() % 100) - (rand() % 100);
    }
    if(rand() % 100 < mutatechance)
    {
        ImmuneResistance += (rand() % 100) - (rand() % 100);
    }
    if(rand() % 100 < mutatechance)
    {
        StartingHp += (rand() % 100) - (rand() % 100);
    }

    Virulence = Utils::clamp(Virulence, 0, 1000);
    Infectivity = Utils::clamp(Infectivity, 0, 1000);
    DrugResistance = Utils::clamp(DrugResistance, 0, 1000);
    ImmuneResistance = Utils::clamp(DrugResistance, 0, 1000);
    StartingHp = Utils::clamp(DrugResistance, 1, 1000);

    Hp = StartingHp;
}

